package org.wtframework.platform.server.model.impl;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.Proxy;
import org.openredhead.springx.core.server.model.IBasicObject;
import org.openredhead.springx.core.server.model.ICompositorObject;

@Entity
@Proxy(lazy = true)
@DynamicInsert(value = true)
@DynamicUpdate(value = true)
@Table(name = "orh_sx_useractivate")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class UserActivate implements IBasicObject,ICompositorObject<Integer> {

	private static final long serialVersionUID = 6265336598741005142L;

	private Integer id;

	private String username;

	private String code;

	private Date activateTime = new Date();
	
	private Integer orderId;
	
	private Boolean activate = false;


	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	

	@Column(name = "order_id")
	public Integer getOrderId() {
		return orderId;
	}

	public void setOrderId(Integer orderId) {
		this.orderId = orderId;
	}



	@Column(name = "code_value")
	public String getCode() {
		return code;
	}

	
	public void setCode(String code) {
		this.code = code;
	}

	@Column(name = "activate_time")
	public Date getActivateTime() {
		return activateTime;
	}

	
	public void setActivateTime(Date activateTime) {
		this.activateTime = activateTime;
	}
	
	public Boolean getActivate() {
		return activate;
	}

	
	public void setActivate(Boolean activate) {
		this.activate = activate;
	}
	
	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object o) {

		if (o == null) return false;

		if (!(o instanceof UserActivate)) return false;

		final UserActivate instance = (UserActivate) o;

		if (getId() != null ? !getId().equals(instance.getId()) : instance.getId() != null) return false;

		return true;

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {

		return (getId() != null ? getId().hashCode() : 0);

	}

}
